#ifndef PLINTH_REVEL_ENCODER_H
#define PLINTH_REVEL_ENCODER_H

#include "../core/AbstractObject.h"
#include "../core/SimpleImage.h"

// Hack to force library initialization
int returnFourPlusX(int x);

class RevelEncoder : public AbstractObject
{
public:
	RevelEncoder();
	~RevelEncoder();

	//OBJTYPE RevelEncoder

	//POP_FUNC SimpleImage*
	//SimpleImage* a%(argPos)d = pop_custom<SimpleImage>(L, %(luaPos)d, "SimpleImage");

	//LIAG_THESE
	void startEncoding(int imgWidth, int imgHeight, float quality, float framerate, const std::string& filename);
	void finalizeEncoding();
	void encodeFrame(SimpleImage* frame);
	//STOP_LIAG

	// Genero AbstractObject stuff below

	// Return the c++ type id
	int getCppTypeId();
	// Returns whether this can be cast to a given type
	bool isType(int id);

	// Return the c++ type as a string 
	std::string getCppTypeName();

	// returns a description of this thing
	std::string getDescription();

	// create another one of these
	AbstractObject* newInstance();

	// init & update
	void init();
	void update(double dt);

	// push its static functions into the given lua table
	void pushStaticFuncs(lua_State* L);
private:
	int _encHandle;
	bool _currentlyEncoding;
	bool _nogood;
	int _w;
	int _h;
	
	struct RevelData;
	RevelData *_revData;
};

#endif